Repository navigation
Conversation
…s-development Their best match lives only on gynt's catch-all branches, which are ~2080 cpp files ahead of their merge base and 412 commits behind main. The cpp files are copied unchanged, without the headers of those branches: - gynt/reimpl/UI-DisplayElements-pr-development@fbc092e15 (1) - gynt/reimpl/UI-MenuItems-development@405b98871 (7) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
Renamed fields, globals and resolvers by address, enum-typed arguments, array fields indexed directly, clang-format. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
SHC_3BB0A8C1_0x004476B0 69.0% MenuItemRenderFunction_BuildingAndStatusMenu_BuildingWorkStatus SHC_3BB0A8C1_0x0045EF90 51.6% MenuItemRenderFunction_TextEditor_Scrollbar SHC_3BB0A8C1_0x004940B0 78.0% MenuItemActionHandler_SoundOptions_Buttons SHC_3BB0A8C1_0x004AEF70 59.1% MenuItemRenderFunction_Roundtable_Main SHC_3BB0A8C1_0x004BFE20 24.1% MenuItemActionHandler_UnusedCreateMessageEvent_SetTextUnk SHC_3BB0A8C1_0x004BFFA0 87.6% MenuItemRenderFunction_General_EventButtonAndData SHC_3BB0A8C1_0x004C1770 46.3% MenuItemActionHandler_General_CreateEventCallbackFunction SHC_3BB0A8C1_0x004F4290 42.0% handleMenuElementsCallbacks Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
- UnusedCreateMessageEvent_SetTextUnk 24.1 -> 84.0: a switch with the arms in the original's layout order (0x25, 0x13, -1), month reset at >= 12. Left: our compiler merges the 0x13 arm's trailing calls into the 0x25 arm. - TextEditor_Scrollbar 51.6 -> 76.5: the right edge is x + 20 kept in a local, horizontal lines end at right - 1. Left: register naming. - SoundOptions_Buttons 78.0 -> 86.6: the sound toggle is a plain if/else with tail calls (Ghidra turned it into a fall-through), cases in jump-table target order, the slider locals scoped to their cases so the other arms tail-call. Left: the original keeps 0 in a register for the compare and the store. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
76.5 -> 82.4. Declaring `top` ahead of drawScrollbar gives it ebx as in the original; y and right - 1 still trade ebp and edi. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
69.0 -> 87.8. - With needed workers and some employed, only "needed + 4" is shown; the old code also printed "No labour" after it. - When none of the workers is a peasant on his way, the function goes on to the building-type switch instead of returning, as the original does. The unit it passes there is the last worker the loop read; with no workers it is an uninitialised local, which is the stack slot the original reads. - Plain loops and named locals replace the pointer walks and iVar names. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
59.1 -> 97.2. - The selected-seat dimBox and the team icon no longer return early; in the original both fall through to the name text. - In the dragged-seat (200) branch, drawing the face now returns instead of falling through to draw icon 0x21c on top of it. - The trailing interacting/blend block is gone from the end of the function: the original only runs it for button 0x14. The AI name lookup is an inline argument of the render call, and the empty-seat exit shares the final epilogue. What is left is the scheduling of the AI name index loads. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
42.0 -> 62.2. - Buttons come before sliders, and the menu->one slider arm before the other, as in the original's fall-through order. - Each slider arm declares its own min/max/value pointers; the first clamp of the dragging arm reads the fields directly. - The right-click (type 4) and left-click paths share one click block, selected by a ternary instead of the decompiler's goto. - The sound arm tests sound != 1 first, so the 2..7 range is the fall-through. What is left is register allocation: ebx and ebp hold each other's roles (constant 1 and the timeGetTime pointer), and the slider keeps thumb in a stack slot where the original uses ebx. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
46.3 -> 86.3 (measured with the finished clearAnyOtherModalDialogs resolver enabled, as for the rest of the namespace). - Bandits and archers (0x92, 0x94) opened the event slider dialog twice; the original opens it once. - Each case calls playEventVideoBik with its own text index, video and wav, then clears the dialogs, instead of staging them in shared variables for a call after the switch. The original pushes the literals per case and jumps into one shared call. - The 192 in-range no-op values are the switch default, as the index table shows. - unitSelectionIndex is initialised at the top: the original zeroes edi in the prologue and the bandits loop starts from it. - The lion case scopes its spawn x local to its block. With a function-scope address-taken local MSVC emits no tail calls anywhere, while the original tail-calls clearAnyOtherModalDialogs. What is left is the second zero register (ebx in the original, ebp here) and the tail-merge choices of a few cases. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The original loads *min before computing the range and reuses that one value for the `+ min` and the clamp after the store to *value. The range gets its own local instead of reusing the x-position variable. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
The original checks for the text/state item type first and returns 0 at once when its right click is not set, while every other type tests the left click; the ternary over both flags compiled to a load and test of a selected flag instead. Spelling out the two arms gives the original's compare-against-memory form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ
|
Style guide reading (advisory, posted once) 37 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 6 of the 8 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 9 — Prefer
Rule 11 — No magic addresses
Rule 16 — Give variables a name that says what they hold
Rule 18 — Use the name, not the number
Rule 22 — Prefer descriptive code
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The .cpp is unchanged; the full build plus reccmp after merging origin/main (both resolver sets enabled) measures 86.0 instead of the recorded 86.3. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
… two BuildingWorkStatus: compare the building type straight from the building (no BuildingTypeShort local: that cost a second movzx per compare) and pick the "No labour"/"needed + 4" text index into a local before a single renderText2 call. reg_scores.py shows why: with two calls the `needed` local (benefit 18) outranks `employees` (16) and takes eax, while the original has employees in eax; with the text index in a local the original's register assignment comes out. The original still has two calls there (only the four constant pushes hoisted), so the shared call is the remaining difference. quick_diff 0.9032 -> 0.9538, reccmp 87.8% -> 89.0%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…0x24 handleMenuElementsCallbacks: declare the slider's offset and insideThumb (both start at 0) before the "no click" early return, as the original does: the zero then lives in eax for the two flag compares and the return value. reccmp 67.0% -> 70.7%. The rest is register allocation in the slider/scrollbar half: the original keeps size in ebp and the item x in ebx with a 0x24 frame, ours spills size and needs 0x28. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
CreateEventCallbackFunction: write the stone keep and the stronghold as two else-if arms with identical bodies (the original's `cmp 0x29; je; cmp 0x2a; jne; body` is the cross-jumped pair, not an `||`), and test xyAreValid's result directly instead of through Ghidra's comma expression (`test eax, eax` instead of `cmp eax, <zero reg>`). reccmp 86.0% -> 87.0%. Remaining: the function-wide zero lives in ebp, the original's in ebx. reg_scores.py: the zero is served late with ebx at cost 0 and ebp/esi/edi at -1 (copy affinities), so it takes ebp; that also changes the push order, the [esp+N] offsets inside the cases and which copy of the shared playEventVideoBik tail survives cross-jumping. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…/tribe local The original keeps case 0x91's spawn x and case 0x94's second (monk) tribe in the same stack slot ([esp + 0x10]). So declare one function-scope local for both instead of a case-local spawnX plus a dStack_4. Because the local is address-taken, the monk tribe now stays on the stack as in the original, instead of taking ebx. That frees ebx for the function-wide zero, which reg_scores had shown going to ebp. The constant 2 (ULS_NORMAL) again takes ebx in the case 0x92/0x94 loops. Remaining: dVar5/dVar6 and the first loop counter in case 0x94 sit in edi/ebp swapped, and some playEventVideoBik/clearAnyOtherModalDialogs tails are laid out differently. reccmp 87.0% -> 90.0% (full build, both resolver sets enabled). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
gynt
added a commit
to gynt/OpenSHC
that referenced
this pull request
Dec 4, 2026
- SoundOptions_Buttons: the reset-volume cases pass their own currentValue local instead of reusing the click-type parameter's slot through an enum cast, the comment explaining that form is gone, and the genie toggle tests the flag by truthiness. Re-measured on main 592a17d with a full build and reccmp, unchanged: 87.6 / 97.2 / 86.6 / 82.4, all still register allocation only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…reak (90.0 -> 95.9) Case 0x91 now takes the address of its own block-scoped spawnX/spawnY instead of a shared function local and param_1. With both addresses taken on function-wide variables MSVC dropped every tail call; the original tail-calls clearAnyOtherModalDialogs four times. The event cases of the inner switch end with break, so they share the clearAnyOtherModalDialogs call after the switch as in the original. Legacy iVarN/dVarN names replaced by names per use. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Record the blockers found for BuildingWorkStatus, EventButtonAndData, UnusedCreateMessageEvent_SetTextUnk and handleMenuElementsCallbacks. Scores unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
8 menu-item render and action handlers, rebuilt from the asm. The functions were ported from gynt's catch-all branches: this branch is origin/main plus the copied files, compile fixes, matching work and status.
Measured with reccmp, with both the struct and the function resolvers enabled and main's /GL callees on.
0 of 8 functions at 100%. The others hit a wall: the blocker named for each was measured, and the source forms tried against it tied or scored worse.
Hit a wall
Roundtable::MenuItemRenderFunction_Roundtable_MainBuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_BuildingWorkStatusemployeesandneededswapeax/edx; theneededarms share the x/y loads.General::MenuItemRenderFunction_General_EventButtonAndDataSoundOptions::MenuItemActionHandler_SoundOptions_Buttonseaxfor the toggle; ten source forms tie.General::MenuItemActionHandler_General_CreateEventCallbackFunctionebxin the original andebphere; tail-merge choices of a few cases.Unused::MenuItemActionHandler_UnusedCreateMessageEvent_SetTextUnkTextEditor::MenuItemRenderFunction_TextEditor_Scrollbaryandright - 1swapebp/edi.MenuItem::handleMenuElementsCallbacksebx/ebprole swap, and the slider spills the thumb position.Behaviour fixes
These were wrong in the decompiler output and are fixed against the binary:
Roundtable_Main: the selected-seat box and team icon no longer return early, the dragged-seat face no longer gets icon 0x21c drawn over it, and the trailing interacting/blend block runs only for button 0x14.BuildingWorkStatus: with needed workers and some employed only "needed + 4" is shown (it also printed "No labour"), and the function goes on to the building-type switch when no worker is a peasant on his way.CreateEventCallbackFunction: bandits and archers opened the event slider dialog twice.Type and header changes are in their own
types:commits. Resolver flags are not committed.🤖 Generated with Claude Code
https://claude.ai/code/session_01XmXCmXNCM9MzSpvzeakUrQ